using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using dnAnalytics.Math;
using dnAnalytics.LinearAlgebra;
using dnAnalytics.Exceptions;

namespace dnAnalytics.UnitTests.LinearAlgebra
{
    public class ArrayVector : Vector
    {
        private double[] data;

        public ArrayVector(int size)
            : base(size)
        {
            data = new double[size];
        }
        
        public override double this[int index]
        {
            get
            {
                return data[index];
            }
            set
            {
                data[index] = value;
            }
  
        }

        protected override Vector CreateVector(int size)
        {
            return new ArrayVector(size);
        }
    }


    [TestFixture]
    [Category("Managed")]
    public class UserDefinedVectorTest : AbstractVectorTest
    {
        public override Vector GetVector(int order)
        {
            return new ArrayVector(order);
        }

        public override Vector GetVector(int order, double value)
        {
            ArrayVector ret = new ArrayVector(order);
            for (int i = 0; i < order; i++)
            {
                ret[i] = value;
            }
            return ret;
        }

        public override Vector GetVector(double[] data)
        {
            ArrayVector ret = new ArrayVector(data.Length);
            for (int i = 0; i < data.Length; i++)
            {
                ret[i] = data[i];
            }
            return ret;
        }

        public override Matrix GetMatrix(int rows, int columns)
        {
            return MatrixBuilder.CreateMatrix(rows, columns, MatrixType.Dense);
        }
    }
}
